<template>
	<view>
		<view class="boxes uniBtn" v-for="(item,index) in list" :key="index">
			<view class="uniFlex box" @click="edit(item.id)">
				<image v-if="item.default==1" class="icon" src="../../static/main/a11.png" mode=""></image>
				<image v-else class="icon" src="../../static/main/a12.png" mode=""></image>
				<view>
					<view class="uniFlex">
						<view>{{item.name}} {{item.number}}</view>
						<view class="understand" v-show="item.default==1">默认</view>
					</view>
					<view>{{item.city}}{{item.area}}{{item.address}}</view>
				</view>
			</view>
			<image class="edit" src="../../static/main/a10.png" mode=""></image>
		</view>
		
		<view @click="add" class="other-button" hover-class="other-button-hover">新增地址</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:[
					// {id:1,type:2},
					// {id:2,type:1},
					// {id:3,type:2},
					// {id:4,type:2}
				]
			}
		},
		onShow() {
			this.list = [];
			this.getList();
		},
		methods: {
			async getList(){
				let res = await this.$api.listcode({
					uid: uni.getStorageSync("tokenUid")
				});
				if(res.code == 200){
					// console.log(res)
					this.list=res.data;
				}
			},
			tab(id,index){
				this.list.forEach(item=>{
					item.type = 2;
					if(item.id == id){
						item.type = 1;
					}
				})
			},
			add(){
				uni.navigateTo({
					url:'/pages/houseid/add/add'
				})
			},
			edit(id){
				uni.navigateTo({
					url:'/pages/houseid/edit/edit?id='+id
				})
			}
		}
	}
</script>

<style scoped lang="scss">
page{
	background: #fff;
}
.boxes{
	padding: 30upx;
	font-size: 30upx;
	.box{
		.icon{
			width: 38upx;
			height: 38upx;
			margin-right: 20upx;
		}
		.uniFlex{
			margin-bottom: 5upx;
			.understand{
				background: #FC6CA7;
				color: #fff;
				font-size: 24upx;
				margin-left: 24upx;
				padding: 5upx 15upx;
				border-radius: 15upx;
			}
		}
	}
	.edit{
		width: 32upx;
		height: 32upx;
	}
}
</style>
